﻿<style type="text/css">
    #resumen input, #resumen input[disabled]
    {
        color: #000 !important;
        font-weight: bold;
    }

    @media print, screen
    {
        #estadoDeCuenta tr.break td
        {
            color: #fff !important;
            background-color: #000 !important;
        }
    }
</style>
<?php if ($sinRegistros === false) : ?>
    <button class='btn btn-warning hidden-print' type='button' onclick='window.print()'>
        Imprimir estado de cuenta
    </button>
    <br class='hidden-print'/>
    <br class='hidden-print'/>
    <?php if ($prestamoVigente === true) : ?>
        <?php if ($prestamoMultiple === false): ?>
            <div class="panel">
                <div class="panel-heading">Generales del pr&eacute;stamo</div>
                <div class="panel-body">
                    <form role="form" id="resumen">
                        <div class="col-lg-6 col-sm-6 col-xs-6">
                            <div class="form-group">
                                <label class="control-label">
                                    Nombre:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Nombre']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    <attr title="Registro federal de contribuyentes">R.F.C.</attr>:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['R.F.C.']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    No. de cuenta:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['No. de cuenta']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Delegaci&oacute;n:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Delegacion']; ?>">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-sm-3 col-xs-3">
                            <div class="form-group">
                                <label class="control-label">
                                    Folio pr&eacute;stamo:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Folio prestamo']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Importe pr&eacute;stamo:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Importe prestamo']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Monto total a pagar:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Monto total a pagar']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Plazo:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Plazo']; ?>">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-sm-3 col-xs-3">
                            <div class="form-group">
                                <label class="control-label">
                                    Pago mensual:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Pago mensual']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Inter&eacute;s mensual:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Interes mensual']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">
                                    Mes inicio:
                                </label>
                                <div>
                                    <input type="text" class="form-control" disabled="disabled" value="<?php echo $usuario['Mes inicio']; ?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <div>
                                    <strong>Recuperaciones:</strong> <?php echo $usuario['Pagos realizados']; ?>
                                </div>
                                <div class="row">
                                    <div class="pull-left has-success col-lg-6 col-sm-6 col-xs-6">
                                        <label class="control-label">OK:</label>
                                        <input type="text" class="form-control text-center" disabled="disabled" value="<?php echo $usuario['Pagos correctos']; ?>">
                                    </div>
                                    <div class="pull-right has-error col-lg-6 col-sm-6 col-xs-6">
                                        <label class="control-label">Incidencia:</label>
                                        <input type="text" class="form-control text-center" disabled="disabled" value="<?php echo $usuario['Pagos con error']; ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        <?php else: ?>
            <div class="panel">
                <div class="panel-heading">Generales del pr&eacute;stamo</div>
                <div class="panel-body">
                    <div class="alert alert-info">
                        Se encontraron <strong><?php echo count($prestamos); ?></strong> pr&eacute;stamos vigentes
                    </div>
                    <table class="table table-bordered table-condensed table-striped">
                        <thead>
                            <tr>
                                <th>Nombre</th>
                                <th>
                        <attr title="Registro federal de contribuyentes">R.F.C.</attr>
                        </th>
                        </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>
                                    <?php echo $prestamos[0]['creditos']['nombre'] . ' ' . $prestamos[0]['creditos']['paterno'] . ' ' . $prestamos[0]['creditos']['materno']; ?>
                                </td>
                                <td><?php echo $prestamos[0]['creditos']['rfc']; ?></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-bordered table-condensed table-striped">
                        <thead>
                            <tr>
                                <th>Folio</th>
                                <th>No. cuenta</th>
                                <th>Plazo</th>
                                <th>Fecha de instrucci&oacute;n</th>
                                <th>Delegaci&oacute;n</th>
                                <th>Importe pr&eacute;stamo</th>
                                <th>Monto total a pagar</th>
                                <th>Pago mensual</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            foreach ($prestamos as $prestamo) :
                                $p = $prestamo['creditos'];
                                ?>
                                <tr>
                                    <td><?php echo $p['folio']; ?></td>
                                    <td><?php echo $p['cuenta_bancaria']; ?></td>
                                    <td><?php echo $p['plazo']; ?></td>
                                    <td><?php echo $p['fecha_instrumento']; ?></td>
                                    <td><?php echo $p['delegacion']; ?></td>
                                    <td>$<?php echo number_format($p['monto_original'], 2, '.', ','); ?></td>
                                    <td>$<?php echo number_format($p['total_pago'], 2, '.', ','); ?></td>
                                    <td>$<?php echo number_format($p['pago_mensual'], 2, '.', ','); ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        <?php endif; ?>
    <?php else : ?>
        <div class="alert alert-info">
            <p>
                Actualmente no tienes un pr&eacute;stamo vigente.
            </p>
            <p>
                A continuaci&oacute;n te presentamos un hist&oacute;rico de las recuperaciones que
                ha(n) generado el(los) cr&eacute;dito(s) que te fueron otorgados.
            </p>
        </div>
    <?php endif; ?>
    <div class="panel">
        <div class="panel-heading">
            <?php echo $tituloRecuperaciones; ?>
        </div>
        <table id="estadoDeCuenta" class="table table-condensed table-striped table-hover table-bordered">
            <thead>
                <tr>
                    <th class="date text-center">A&ntilde;o / mes</th>
                    <th class="importe text-center">Importe cobrado</th>
                    <th class="text-center">Cuenta bancaria</th>
                    <th class="observacion text-center">Observaci&oacute;n</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($recuperaciones as $recuperacion): ?>
                    <?php if (isset($recuperacion['break']) === true): ?>
                        <tr class="break">
                            <td>Liquidaci&oacute;n / restructuraci&oacute;n de cr&eacute;dito</td>
                            <td>
                                <span class="pull-left">Total pagado $</span>
                                <span class="pull-right">
                                    <?php echo number_format($recuperacion['total'], 2, '.', ','); ?>
                                </span>
                            </td>
                            <td colspan="2">
                                OK: <strong><?php echo $recuperacion['ok']; ?></strong>, INCIDENCIAS: <strong><?php echo $recuperacion['error']; ?></strong>
                            </td>
                        </tr>
                    <?php else: ?>
                        <tr <?php echo $recuperacion['recuperacion']['pago_exitoso'] === false ? 'class="danger"' : '' ?>>
                            <td class="date visible-lg visible-sm">
                                <?php echo $recuperacion[0]['dateLong']; ?>
                            </td>
                            <td class="dateSmall visible-md visible-xs">
                                <?php echo $recuperacion[0]['dateShort']; ?>
                            </td>
                            <td class="importe">
                                <span class="pull-left">$</span>
                                <?php if ($recuperacion['recuperacion']['monto'] > 0 && $recuperacion['recuperacion']['pago_exitoso'] === true): ?>
                                    <span class="pull-right">
                                        <?php echo number_format($recuperacion['recuperacion']['monto'], 2, '.', ','); ?>
                                    </span>
                                <?php else: ?>
                                    <span class="pull-right">
                                        -
                                    </span>
                                <?php endif; ?>
                            </td>
                            <td class="importe text-right">
                                <?php if ($recuperacion['recuperacion']['monto'] > 0 && $recuperacion['recuperacion']['pago_exitoso'] === true): ?>
                                    <?php echo $recuperacion['recuperacion']['cuenta_bancaria']; ?>
                                <?php else: ?>
                                    -
                                <?php endif; ?>
                            </td>
                            <td class="observacion">
                                <?php echo $recuperacion[0]['observacion']; ?>
                            </td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <button class='btn btn-warning hidden-print' type='button' onclick='window.print()'>
        Imprimir estado de cuenta
    </button>
<?php else : ?>
    <div class="alert alert-info">
        No se encontraron recuperaciones ni cr&eacute;ditos activos.
    </div>
<?php endif; ?>
